
public class Method {
    public static void isLeapYear(int year) {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            System.out.println(year + "是闰年");

        } else {
            System.out.println(year + "不是闰年");
        }
    }

    public static void main1(String[] args) {
        int year1 = 1900;
        int year2 = 1901;
        isLeapYear(year1);
        isLeapYear(year2);
    }


    public static void swap(int a, int b) {
        int temp = a;
        a = b;
        b = temp;
    }

    public static void main2(String[] args) {
        int a = 100;
        int b = 200;
        System.out.println("交换前 a = " + a + ", b = " + b);
        swap(a, b);
        System.out.println("交换后 a = " + a + ", b = " + b);
    }


    public static void swap(int[] array) {
        int temp = array[0];
        array[0] = array[1];
        array[1] = temp;
    }

    public static void main3(String[] args) {
        int[] array = {100, 200};
        System.out.println("交换前 array[0] = " + array[0] + ", array[1] = " + array[1]);
        swap(array);
        System.out.println("交换后 array[0] = " + array[0] + ", array[1] = " + array[1]);
    }


    public static int add(int a, int b) {
        return a + b;
    }

    public static float add(float a, float b) {
        return a + b;
    }

    public static int factor(int n) {
        if (n == 1) {
            return 1;
        }
        return factor(n - 1) * n;
    }

    public static void main(String[] args) {
        int sum1 = add(100, 200);
        System.out.println(sum1);
        float sum2 = add(1.0F, 2.0F);
        System.out.println(sum2);
        System.out.println("============================");
        System.out.println(factor(5));
    }
}